package com.jlkf.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jlkf.dao.DriverMonthlyIncomeMapper;
import com.jlkf.dao.DriverWeekIncomeMapper;
import com.jlkf.pojo.DriverMonthlyIncome;
import com.jlkf.service.ReportService;
import com.platform.server.response.response.pojo.ReturnData;
import com.platform.server.util.StringTools;

@Service
public class ReportServiceImpl implements ReportService{

	@Autowired
	private DriverMonthlyIncomeMapper driverMonthlyIncomeMapper;
	@Autowired
	private DriverWeekIncomeMapper driverWeekIncomeMapper;
	@Override
	public Object getDriverMonthlyIncomeList(String year,String mouth, Integer pageNo, Integer pageSize) {
		Map<String,Object> map = new HashMap<>();
		if(!StringTools.isEmptyAll(year)&&!StringTools.isEmpty(mouth)){
			map.put("yearAndMouth", year+"-"+mouth);
		}
		try {
			PageHelper.startPage(pageNo, pageSize);
			List<DriverMonthlyIncome> list = driverMonthlyIncomeMapper.getDriverMonthlyIncomeList(map);
			PageInfo<DriverMonthlyIncome> info =new PageInfo<>(list);
			int total = (int) info.getTotal();
			int totalPages = info.getPages();
			return new ReturnData(list,totalPages,total,200,"driverMonthlyIncome_list");
		} catch (Exception e) {
			e.printStackTrace();
			return new ReturnData(500,"Wow, that's wrong");
		}
	}
	
	
}
